package com.apple.hsytrix.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * Created by lidongji on 2017/8/29.
 */
@Service
public class ConsumerService {
    @Autowired
    RestTemplate restTemplate;
    @HystrixCommand(fallbackMethod = "fallback")// @HystrixCommand 指定降级方法
    public String consumer() {
        return restTemplate.getForObject("http://eureka-springboot/hello", String.class);
    }
    public String fallback() {
        return "fallback";
    }

}
